home *** CD-ROM | disk | FTP | other *** search
- // (C) Copyright Microsoft Corp. 1991. All rights reserved.
- //
- // You have a royalty-free right to use, modify, reproduce and
- // distribute the Sample Files (and/or any modified version) in
- // any way you find useful, provided that you agree that
- // Microsoft has no warranty obligations or liability for any
- // Sample Application Files which are modified.
-
-
- /****************************************************************************
-
- MODULE : PLAYVFW.C
-
- PURPOSE : This application implements Video For Windows and Audio playback in an interactive and
- configurable manner. The program reads several ini files to get position information as
- well as file names for the VFW and audio files. These ini files are completely configurable
- by the end user.
-
- FUNCTIONS :
-
- PlayVFWWinProc
- WinMain
- Transition
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 8/12/93
-
- ****************************************************************************/
-
- #include "windows.h"
- #include <stdlib.h>
- #include "playvfw.h"
- #include "proto.h"
- #include "mmsystem.h"
- #include <digitalv.h>
- #include <stdio.h>
- #include <time.h>
- #include <viewer.h>
-
-
-
- /****************************************************************************
-
- FUNCTION : WinMain( HANDLE, HANDLE, LPSTR, int )
-
- PURPOSE : This function is where are the application initialization occurs. The main window
- for the application is created here as well as global memory for the device structures.
- The cursors are loaded and the startup screen bitmap is loaded from the resource file. This
- Function also contains the main message loop for the application.
-
- COMMENTS :
-
- HISTORY : Created by Steven Molstad 6/1/93
-
- ****************************************************************************/
-
- int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
- HANDLE hInstance, hPrevInstance;
- LPSTR lpszCmdLine;
- int cmdShow;
- {
- MSG msg;
- HWND hWnd;
-
- HDC hDC;
- HDC hdcMemory;
- HBITMAP hbmpMyBitmap, hbmpOld,hbmpMyBitmap2;
- BITMAP bm;
- RECT Points;
-
- if (!hPrevInstance) {
- /* Call initialization procedure if this is the first instance */
- if (!PlayVFWInit( hInstance ))
- return FALSE;
- }
- else
- {
- MessageBox(NULL,"Can only run one instance of this application","ERROR",MB_OK);
- return FALSE;
- }
-
- // Check to see if we are running NT, if we are shut the program down.
-
- if (fNTRunning())
- {
- MessageBox(NULL,"Cannot run this application under NT","ERROR",MB_OK);
- return FALSE;
- }
-
- // Check to see if we are running in a supported Resolution and support color mode. If we are not
- // warn the user that he may not get the best results.
-
- if (!fHiResCapable())
- if (!fVgaCapable() || !f256Capable())
- MessageBox(NULL,"For best results use either 1024 X 768 >= 256 color mode or 640 X 480 >= 256 color mode","Note:",MB_OK);
-
- // Check to see if there is a sound device if not stop all calls to the sound API otherwise call them.
- // This way we don't crash when there is no sound device.
-
- if (!cNumAudio())
- bNoSound=TRUE;
- else
- bNoSound=FALSE;
-
-
-
-
- // Allocate memory for each of the different devices (owner draw buttons). This program contains up
- // to 8 different devices which can be active at any given time. A device structure describes the
- // different attributes of an owner draw button. For example the device ID of the AVI file displayed
- // in the owner draw button is stored in the hDevice structure.
-
-
- hDevice1=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice2=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice3=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice4=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice5=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice6=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice7=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice8=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
- hDevice9=GlobalAlloc(GHND,sizeof(DEVICESTRUCT));
-
- hDirs=GlobalAlloc(GHND,sizeof(DIRSTRUCT));
-
-
- // make sure all of the memory was allocated. If not drop out of the program.
-
- if (!hDevice1 && !hDevice2 && !hDevice3 && !hDevice4 && !hDevice5 && !hDevice6 && !hDevice7 && !hDevice8 && !hDevice9 && !hDirs)
- {
- MessageBox(NULL,"The Initial memory allocation failed aborting program","ERROR",MB_OK);
- return FALSE;
- }
-
- // lock all the memory once so it can be used in the rest of the program.
-
- lpDevice1=(LPDEVICESTRUCT)GlobalLock(hDevice1);
- lpDevice2=(LPDEVICESTRUCT)GlobalLock(hDevice2);
- lpDevice3=(LPDEVICESTRUCT)GlobalLock(hDevice3);
- lpDevice4=(LPDEVICESTRUCT)GlobalLock(hDevice4);
- lpDevice5=(LPDEVICESTRUCT)GlobalLock(hDevice5);
- lpDevice6=(LPDEVICESTRUCT)GlobalLock(hDevice6);
- lpDevice7=(LPDEVICESTRUCT)GlobalLock(hDevice7);
- lpDevice8=(LPDEVICESTRUCT)GlobalLock(hDevice8);
- lpDevice9=(LPDEVICESTRUCT)GlobalLock(hDevice9);
-
-
- lpDirs=(LPDIRSTRUCT)GlobalLock(hDirs);
-
- // Make sure that the memory could be locked.
-
- if (!lpDevice1 && !lpDevice2 && !lpDevice3 && !lpDevice4 && !lpDevice5 && !lpDevice6 && !lpDevice7 && !lpDevice8 && !lpDevice9 && !lpDirs)
- {
- MessageBox(NULL,"The Initial memory lock failed aborting program","ERROR",MB_OK);
- return FALSE;
- }
-
-
- hWnd = CreateWindow((LPSTR)szAppName,
- (LPSTR)szMessage,
- WS_OVERLAPPED | WS_MAXIMIZE,
- CW_USEDEFAULT, /* x - ignored for tiled windows */
- CW_USEDEFAULT, /* y - ignored for tiled windows */
- CW_USEDEFAULT, /* cx - ignored for tiled windows */
- CW_USEDEFAULT, /* cy - ignored for tiled windows */
- (HWND)NULL, /* no parent */
- (HMENU)NULL, /* use class menu */
- (HANDLE)hInstance, /* handle to window instance */
- (LPSTR)NULL /* no params to pass on */
- );
-
-
- hWndMain=hWnd;
-
- bButtonDown=FALSE;
- hOld=0;
-
- /* Save instance handle for DialogBox */
- hInst = hInstance;
-
-
- // Load a cursor for each window.
-
- lpDevice1->hCursor=LoadCursor( hInstance, MAKEINTRESOURCE(BUTTON1CURSOR) );
- lpDevice2->hCursor=LoadCursor( hInstance, MAKEINTRESOURCE(BUTTON2CURSOR) );
- lpDevice3->hCursor=LoadCursor( hInstance, MAKEINTRESOURCE(BUTTON3CURSOR) );
- lpDevice4->hCursor=LoadCursor( hInstance, MAKEINTRESOURCE(BUTTON4CURSOR) );
- lpDevice5->hCursor=LoadCursor( hInstance, MAKEINTRESOURCE(BUTTON5CURSOR) );
- lpDevice6->hCursor=LoadCursor( hInstance, MAKEINTRESOURCE(BUTTON6CURSOR) );
-
- hHelloCursor=LoadCursor( NULL, IDC_ARROW );
-
- hWndButtonBar=0;
-
-
- // The following code loads a bitmap from the resource file and displays it centered on
- // on the page.
-
- hbmpMyBitmap = LoadBitmap(hInst, "newlogo");
- GetObject(hbmpMyBitmap, sizeof(BITMAP), &bm);
-
- hDC = GetDC(hWnd);
- hdcMemory = CreateCompatibleDC(hDC);
- hbmpOld = SelectObject(hdcMemory, hbmpMyBitmap);
- GetClientRect(hWnd,&Points);
-
- BmpPoints.left=(Points.right/2)-(bm.bmWidth/2);
- BmpPoints.top=(Points.bottom/2)-(bm.bmHeight/2);
-
- /* Make window visible according to the way the app is activated */
-
-
- ShowWindow( hWnd, SW_MAXIMIZE );
- UpdateWindow( hWnd );
-
-
- // Display the bitmap in the window. Then delete the bitmap object as well as the
- // Device context.
-
- BitBlt(hDC, (BmpPoints.left), (BmpPoints.top), bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
-
- SelectObject(hdcMemory, hbmpOld);
-
- DeleteDC(hdcMemory);
-
- ReleaseDC(hWnd, hDC);
-
- DeleteObject(hbmpMyBitmap);
-
- // load the next bitmap and then initialize the windows and devices. In this manner
- // the first bitmap will stay up while the setup of the program is happening. Then
- // we blit the second bitmap and play the VFW file.
-
- hbmpMyBitmap2 = LoadBitmap(hInst, "vgalogo4");
- GetObject(hbmpMyBitmap2, sizeof(BITMAP), &bm);
-
- DeleteObject(hbmpMyBitmap2);
-
- GetClientRect(hWnd,&Points);
-
- BmpPoints.left=(Points.right/2)-(bm.bmWidth/2);
- BmpPoints.top=(Points.bottom/2)-(bm.bmHeight/2);
-
- // retrieve the Video For Windows information as well as the audio information from the
- // initialization files.
-
- if(!InitVFWStuff(hWnd,hInstance))
- return FALSE;
-
- // Nuke the old bitmap by PatBlt BLACKNESS to the full screen.
-
- hDC = GetDC(hWnd);
-
- GetClientRect(hWnd, &Points);
-
- PatBlt(hDC, Points.left, Points.top,
- Points.right, Points.bottom, BLACKNESS);
-
-
- ReleaseDC(hWnd, hDC);
-
- // The following code loads a bitmap from the resource file and displays it centered on
- // on the page.
-
- hbmpMyBitmap = LoadBitmap(hInst, "vgalogo4");
- GetObject(hbmpMyBitmap, sizeof(BITMAP), &bm);
-
- hDC = GetDC(hWnd);
- hdcMemory = CreateCompatibleDC(hDC);
- hbmpOld = SelectObject(hdcMemory, hbmpMyBitmap);
- GetClientRect(hWnd,&Points);
-
- BmpPoints.left=(Points.right/2)-(bm.bmWidth/2);
- BmpPoints.top=(Points.bottom/2)-(bm.bmHeight/2);
-
-
- // Display the bitmap in the window. Then delete the bitmap object as well as the
- // Device context.
-
- BitBlt(hDC, (BmpPoints.left), (BmpPoints.top), bm.bmWidth, bm.bmHeight, hdcMemory, 0, 0, SRCCOPY);
-
- SelectObject(hdcMemory, hbmpOld);
-
- DeleteDC(hdcMemory);
-
- ReleaseDC(hWnd, hDC);
-
-
- DeleteObject(hbmpMyBitmap);
-
- /* Polling messages from event queue */
-
- // hWndButtonBar is the handle to the modeless dialog box which I use as the Video Control bar.
-
- while (GetMessage((LPMSG)&msg, NULL, 0, 0))
- {
- if (hWndButtonBar==0 || !IsDialogMessage(hWndButtonBar,&msg))
- {
- TranslateMessage((LPMSG)&msg);
- DispatchMessage((LPMSG)&msg);
- }
- }
-
- return (int)msg.wParam;
- }
-
- /****************************************************************************
-
- FUNCTION : PlayVFWWndProc( HWND, unsigned, WORD, LONG)
-
- PURPOSE : This is the main Window procedure. This is where the work takes place.
-
- COMMENTS : There are several messages that have to do with the use of owner draw buttons. If I
- was to do it all over I would have probably used Windows VS owner draw buttons. This
- would of excluded the need to use WM_PARENTNOTIFY, WM_SETCURSOR, WM_DRAWITEM messages.
- Instead I could have had an individual window procedure for each child window that would have
- handled the equivalents to these messages more gracefully. For example I would have
- just handled the WM_RBUTTONDOWN in the child window procedure vs having to look for
- WM_PARENTNOTIFY in the parents window procedure.
-
-
- HISTORY : created by Steven Molstad 6/1/93
-
- ****************************************************************************/
-
- /* Procedures which make up the window class. */
-
- long FAR PASCAL PlayVFWWndProc( hWnd, message, wParam, lParam )
- HWND hWnd;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
-
- WORD wCurrentDevice;
-
- int uixPos;
- int uiyPos;
- WORD fActive;
- int count;
- HPALETTE hpal, hPalPrevious;
- HDC hdc;
-
- switch (message)
- {
- case WM_CREATE:
- VWRGlobal=0;
- break;
-
- case WM_SYSCOMMAND:
- switch (wParam)
- {
-
- default:
- return DefWindowProc( hWnd, message, wParam, lParam );
-
- }
- break;
-
- case WM_COMMAND:
- break;
-
-
- // This message is sent to the parent window of an Owner Draw button when some action is taken in
- // that owner draw button. The action I am looking for is a Left Button Down message. Since the
- // Owner draw button has its own window procedure the WM_LBUTTONDOWN message will not be directly
- // sent to the parents window procedure. Inderectly windows sends a WM_PARENTNOTIFY message.
-
- case WM_PARENTNOTIFY:
-
- // When we recieve a WM_PARENTNOTIFY message the action that was taken is represented in the wParam.
- // We are looking for a Left Button click, for simplicity all we care about is that the button was
- // pressed.
-
- if (wParam==WM_LBUTTONDOWN)
- {
- // Grab the X and Y position of the Mouse cursor which is stored in the high and low word of
- // the lParam. This postion will help determine which button the cursor was over when the
- // mouse button was depressed.
-
- uixPos=LOWORD(lParam);
- uiyPos=HIWORD(lParam);
-
- // The transition function creates, displays and plays the morph video.
- // It also takes care of displaying the second page as well as playing
- // back the audio associated with the morph.
-
- if(Transition(lpDevice1,uixPos,uiyPos,1))
- return FALSE;
-
- if(Transition(lpDevice2,uixPos,uiyPos,2))
- return FALSE;
-
- if(Transition(lpDevice3,uixPos,uiyPos,3))
- return FALSE;
-
- if(Transition(lpDevice4,uixPos,uiyPos,4))
- return FALSE;
-
- if(Transition(lpDevice5,uixPos,uiyPos,5))
- return FALSE;
-
- if(Transition(lpDevice6,uixPos,uiyPos,6))
- return FALSE;
-
- // If this is the first page and the right mouse button was pressed over the
- // video window, transition to the 2nd page.
-
- if (bIsPage0)
- DoPage1();
-
- } // end of if wParam == WM_RBUTTONDOWN
-
- if (wParam==WM_RBUTTONDOWN)
- {
-
- // If we are on the last page and someone clicks the right mouse button
- // close the application. To recieve this message the cursor must be
- // over one of the 4 buttons.
-
- //if (bIsPage2)
- PostMessage(hWndMain,WM_CLOSE,0,0L);
- }
-
- return FALSE;
- break;
-
-
- case WM_LBUTTONDOWN:
- if (lstrlen(lpDevice1->szFileName))
- {
-
-
- if (bIsPage2)
- {
-
- // kill viewer when a left mouse button is pressed in the main window.
-
- if (VWRGlobal)
- {
- VwrQuit(VWRGlobal);
- VWRGlobal=0;
- }
-
- // Stop the Video. Hide the Viewer window and show the buttons to avoid any
- // nasty palette changes.
-
- StopVFWFile(lpDevice9->wDeviceID);
-
-
- ShowWindow(lpDevice9->hWnd, SW_HIDE );
- ShowWindow(lpDevice1->hWnd, SW_SHOWNORMAL );
- ShowWindow(lpDevice2->hWnd, SW_SHOWNORMAL );
- ShowWindow(lpDevice3->hWnd, SW_SHOWNORMAL );
- ShowWindow(lpDevice4->hWnd, SW_SHOWNORMAL );
- ShowWindow( hWndButtonBar, SW_HIDE );
-
- SeekAllToStart();
-
-
-
- }
- // }
- }
-
- break;
-
- case MM_MCINOTIFY:
-
- /* This is where we check the status of an AVI */
- /* movie that might have been playing. We do */
- /* the play with MCI_NOTIFY on so we should get */
- /* a MCI_NOTIFY_SUCCESSFUL if the play */
- /* completes on it's own. */
-
- switch(wParam)
- {
- case MCI_NOTIFY_SUCCESSFUL:
- {
-
- // get the ID of the device which the notify is for. This value is
- // stored in the LOWORD of the lParam.
-
- wCurrentDevice=LOWORD(lParam);
-
- // Seek all of the AVI movies to the begining frame.
-
- SeekVFWToStart(wCurrentDevice);
-
-
- // Look for the device which this notify message was meant for. If
- // that device is playing, keep it playing. The bVideoPlaying value
- // will be set to false when the cursor moves to another video window.
-
- if ((wCurrentDevice==lpDevice1->wDeviceID) && lpDevice1->bVideoPlaying)
- PlayVFWFile(hWnd,lpDevice1->hWnd,wCurrentDevice);
-
- if ((wCurrentDevice==lpDevice2->wDeviceID) && lpDevice2->bVideoPlaying)
- PlayVFWFile(hWnd,lpDevice2->hWnd,wCurrentDevice);
-
- if ((wCurrentDevice==lpDevice3->wDeviceID) && lpDevice3->bVideoPlaying)
- PlayVFWFile(hWnd,lpDevice3->hWnd,wCurrentDevice);
-
- if ((wCurrentDevice==lpDevice4->wDeviceID) && lpDevice4->bVideoPlaying)
- PlayVFWFile(hWnd,lpDevice4->hWnd,wCurrentDevice);
-
- if ((wCurrentDevice==lpDevice5->wDeviceID) && lpDevice5->bVideoPlaying)
- PlayVFWFile(hWnd,lpDevice5->hWnd,wCurrentDevice);
-
- if ((wCurrentDevice==lpDevice6->wDeviceID) && lpDevice6->bVideoPlaying)
- PlayVFWFile(hWnd,lpDevice6->hWnd,wCurrentDevice);
-
- // If this is the device ID associated with the video from the initial page
- // setup the second page since we are done playing the video.
-
- if ((wCurrentDevice==lpDevice7->wDeviceID) && lpDevice7->bVideoPlaying && bIsPage0)
- DoPage1();
-
-
- return FALSE;
- }
- }
- break;
-
- case WM_DRAWITEM:
-
- // The draw item message is sent when an owner draw button must be re-drawn due to a
- // mouse click, etc. We take care of this re-drawing in the DrawControl procedure.
-
- DrawControl(hWnd, (LPDRAWITEMSTRUCT)lParam);
- break;
-
-
-
- case WM_CLOSE:
-
- // When the user decides to exit the program we need to cleanup all open
- // MCI devices, Window handles, global memory blocks etc.
-
- Cleanup();
-
- return FALSE;
- break;
-
- /* case WM_ACTIVATE:
- fActive=wParam;
- if (fActive==WA_INACTIVE)
- if (VWRGlobal)
- {
- VwrQuit(VWRGlobal);
- VWRGlobal=0;
- }
-
- break; */
-
- case WM_SETCURSOR:
-
- // A set cursor message is sent when the cursor passes over an owner draw button.
- // This is the only way I can tell if the cursor is over an owner draw button or
- // not. I do not have access to each owner draw button's window procedure so I
- // trap the WM_SETCURSOR message which is sent to the parent of the Window
- // who now has the cursor. The wParam contains the window handle of the owner
- // draw button which now contains the cursor.
-
- if(Playback(wParam,hOld))
- return TRUE;
- else
- return FALSE;
- break;
-
- // This message is sent when the main window is destroyed (DestroyWindow(hWndMain)).
-
- case WM_DESTROY:
- PostQuitMessage( 0 );
- break;
-
- // Let the default behaviour happen when we recieve a WM_PAINT.
-
- case WM_PAINT:
-
- return DefWindowProc( hWnd, message, wParam, lParam );
-
- break;
-
- default:
- return DefWindowProc( hWnd, message, wParam, lParam );
- break;
-
- }
- return(0L);
- }
-
-
- /****************************************************************************
-
- FUNCTION : VideoWndProc( HWND, unsigned, WORD, LONG )
-
- PURPOSE : This is the procedure for the Video Window displayed on page 2.
-
- COMMENTS : This Window is used to display instructional videos for learning. Currently nothing needs
- to be done in this procedure. I let windows handle it all.
-
- HISTORY : Created by Steven Molstad 8/5/93.
-
- ****************************************************************************/
-
-
-
- /* Procedures which make up the window class. */
-
- long FAR PASCAL VideoWndProc( hWnd, message, wParam, lParam )
- HWND hWnd;
- unsigned message;
- WORD wParam;
- LONG lParam;
- {
-
- switch (message)
- {
- case WM_CREATE:
-
- break;
-
- case WM_SYSCOMMAND:
- switch (wParam)
- {
- default:
- return DefWindowProc( hWnd, message, wParam, lParam );
-
- }
- break;
-
- case WM_COMMAND:
- break;
-
- case WM_DESTROY:
- PostQuitMessage( 0 );
- break;
-
-
- default:
- return DefWindowProc( hWnd, message, wParam, lParam );
- break;
- }
- return(0L);
-
- }
-
- /****************************************************************************
-
- FUNCTION : Transition(LPDEVICESTRUCT,int,int,int)
-
- PURPOSE : This procedure takes care of morphing and calling the routine to process the
- next page.
-
- COMMENTS : When transitioning between page 1 and page 2 I re-use the MCI device ID's. That is to
- say I close the old device and re-open the new device vs leaving two devices open.
- This process conserves resource ID's. To speed up the process of transitioning pages
- one could load all the AVI files at the start of the program and leave them open until
- the program shuts down. I opted to conserve resources.
-
-
- HISTORY : Created by Steven Molstad 8/31/93
-
- ****************************************************************************/
-
- BOOL FAR PASCAL Transition(lpDevice,uixPos,uiyPos,device)
- LPDEVICESTRUCT lpDevice;
- int uixPos;
- int uiyPos;
- int device;
-
- {
-
- RECT ChildWinRect;
- HDC hTempDC;
- HANDLE VWR;
- char szCommand[80];
-
-
- // The Function GetRealClientRect is used to retrieve the x,y,dx,dy position of the button.
- // The coordinates retrieved is relative to the top left corner of the client area and not
- // the screen. Therefore these coordinates are relative to what is being returned in the
- // Low and High word of lParam.
-
- GetRealClientRect(lpDevice->hWnd,hWndMain,&ChildWinRect);
-
- // check to see if the button was depressed while the cursor was over the owner draw button.
-
- if ((uixPos < ChildWinRect.right) && (uiyPos > ChildWinRect.top) && (uixPos > ChildWinRect.left) && (uiyPos < ChildWinRect.bottom) )
- {
-
- // if the button was depressed while the cursor was over the owner draw button and this
- // is page 2 do the stuff appropriate to page 2.
-
- if (bIsPage2 && (lpDevice->bPlayAudio || lpDevice->bPlayVideo))
- {
-
- // Different actions happen depending on which of the 4 buttons are pressed
- // on page 2.
-
- switch (device)
- {
- case 1:
- {
-
- // Hide the Window for Device 9, the Video Window, and show the Edit Window.
-
- ShowWindow( lpDevice9->hWnd, SW_HIDE );
-
- // we have to jump to the contents otherwise VwrCommand will not load Viewer.
-
- wsprintf(szCommand,"JumpContents(`%s')",lpDevice1->szFileName);
-
- // grab the handle to viewer if it is already running.
-
- VWR = VwrFromMVB(lpDevice1->szFileName);
-
- // if the Viewer handle it null then run Viewer.
-
- VWR = VwrCommand(VWR, lpDevice1->szFileName, szCommand, cmdoptNONE);
-
- // Get a global handle to Viewer so we can shut it down when necessary.
-
- VWRGlobal = VwrFromMVB(lpDevice1->szFileName);
-
- // we also want to hide all the buttons to avoid any nasty palette problems.
-
- ShowWindow( lpDevice1->hWnd, SW_HIDE );
- ShowWindow( lpDevice2->hWnd, SW_HIDE );
- ShowWindow( lpDevice3->hWnd, SW_HIDE );
- ShowWindow( lpDevice4->hWnd, SW_HIDE );
-
- // Ensure that the Viewer window will stay on top. The position information
- // doesn't position the Viewer window. This needs to be done when authoring
- // the Viewer title.
-
- SetWindowPos(VWRGlobal,(HWND) HWND_TOPMOST,Points3.left,Points3.top,Points3.right,Points3.bottom,SWP_NOACTIVATE);
-
- // hide the button bar.
-
- ShowWindow( hWndButtonBar, SW_HIDE );
-
-
- return TRUE;
- }
-
- case 2:
- {
-
- // Kill the Viewer window and show the video playback control. Since we now hide all
- // the buttons killing the viewer window is useless. Left in to demonstrate the command
- // only.
-
- if (VWRGlobal)
- {
- VwrQuit(VWRGlobal);
- VWRGlobal=0;
- }
-
-
- ShowWindow( lpDevice9->hWnd, SW_SHOWNORMAL );
- ShowWindow( hWndButtonBar, SW_SHOWNORMAL );
-
- // we also want to hide all the buttons to avoid any nasty palette problems.
-
- ShowWindow( lpDevice1->hWnd, SW_HIDE );
- ShowWindow( lpDevice2->hWnd, SW_HIDE );
- ShowWindow( lpDevice3->hWnd, SW_HIDE );
- ShowWindow( lpDevice4->hWnd, SW_HIDE );
-
- return TRUE;
-
- }
-
- case 3:
- {
-
- // hide the edit window, show the video window minimize the application and
- // execute application specified in the ini file.
-
- ShowWindow( hWndEdit, SW_HIDE );
- ShowWindow(lpDevice9->hWnd, SW_SHOWNORMAL );
-
-
- if(lstrlen(lpDevice3->szFileName))
- {
- // we have to jump to the contents otherwise VwrCommand will not load Viewer.
-
- wsprintf(szCommand,"JumpContents(`%s')",lpDevice3->szFileName);
-
- // grab the handle to viewer if it is already running.
-
- VWR = VwrFromMVB(lpDevice3->szFileName);
-
-
- // if the Viewer handle it null then run Viewer.
-
- VWR = VwrCommand(VWR, lpDevice3->szFileName, szCommand, cmdoptNONE);
-
- }
-
- SendMessage(hWndMain,WM_SYSCOMMAND,SC_MINIMIZE,0L);
- return TRUE;
- }
-
- case 4:
- {
-
- // hide the edit window, show the video window, minimize the application and
- // execute application specified in the ini file.
-
- ShowWindow( hWndEdit, SW_HIDE );
- ShowWindow(lpDevice9->hWnd, SW_SHOWNORMAL );
-
- if(lstrlen(lpDevice3->szFileName))
- {
- // we have to jump to the contents otherwise VwrCommand will not load Viewer.
-
- wsprintf(szCommand,"JumpContents(`%s')",lpDevice4->szFileName);
-
- // grab the handle to viewer if it is already running.
-
- VWR = VwrFromMVB(lpDevice4->szFileName);
-
-
- // if the Viewer handle it null then run Viewer.
-
- VWR = VwrCommand(VWR, lpDevice4->szFileName, szCommand, cmdoptNONE);
-
- }
-
- SendMessage(hWndMain,WM_SYSCOMMAND,SC_MINIMIZE,0L);
-
- return TRUE;
-
- }
- }
- return TRUE;
- }
-
- // if it is the first page and Audio or Video is enabled Morph and display next page.
- // If Audio and Video are both disabled the functionality is disabled.
-
- if(bIsPage1 && (lpDevice->bPlayAudio || lpDevice->bPlayVideo) )
- {
-
- // if this is page 1 set that a button was clicked and that there is no video playing.
-
- lpDevice->bRButtonClicked=TRUE;
- lpDevice->bVideoPlaying=FALSE;
- lpDevice->bAudioPlaying=FALSE;
-
- // Reset all video windows to the first frame.
-
- SeekAllToStart();
-
- // Since the morph Window will be displayed over the first window in this case hide window 1.
- // This is not really necessary since the morph window will always be displayed ontop.
-
- ShowWindow( lpDevice->hWnd, SW_HIDE );
-
- // This function does the processing for the morph window.
-
-
- Morph(lpDevice8,device);
-
- //Get the Device Context for the morph window and then update the video in that window.
-
- hTempDC=GetDC(lpDevice8->hWnd);
-
- UpdateVFW (lpDevice8->wDeviceID,hTempDC);
-
- ReleaseDC(lpDevice8->hWnd,hTempDC);
-
-
- // stop all wave files from playing and start a new wave file playing, the wave file
- // for device 8.
-
- StopAllWaveFiles();
-
- if (lpDevice8->bPlayAudio)
- if (lpDevice8->wAudioDeviceID)
- PlayWaveFile(lpDevice8->wAudioDeviceID);
-
- if (lpDevice8->bPlayVideo)
- if (lpDevice8->wDeviceID)
- PlayVFWFileWait(hWndMain,lpDevice8->hWnd,lpDevice8->wDeviceID);
-
-
- // Hide the morph window, close the wave file and the morph avi movie and move on to
- // the next page.
-
- ShowWindow( lpDevice8->hWnd, SW_HIDE );
-
-
- if (lpDevice8->wAudioDeviceID)
- CloseWaveFile(lpDevice8->wAudioDeviceID);
-
-
-
- if (lpDevice8->wDeviceID)
- CloseVFWFile(lpDevice8->wDeviceID);
-
-
- DoNextPage(device);
-
-
-
- } // if bIsPage1
-
-
- // if both audio and video are disabled in the ini file then do nothing and display a dialog
- // box stating that the functionality has been disabled.
-
- if ((!lpDevice->bPlayAudio && !lpDevice->bPlayVideo))
- MessageBox(hWndMain,"Functionality Disabled","DISABLED",MB_OK);
-
- return TRUE;
- }
-
- return FALSE;
- }
-